package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsOutboundOrderMerge;
import com.scau402.system.service.IWmsOutboundOrderMergeService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 出库单合并Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/outboundMerge")
public class WmsOutboundOrderMergeController extends BaseController
{
    @Autowired
    private IWmsOutboundOrderMergeService wmsOutboundOrderMergeService;

    /**
     * 查询出库单合并列表
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsOutboundOrderMerge wmsOutboundOrderMerge)
    {
        startPage();
        List<WmsOutboundOrderMerge> list = wmsOutboundOrderMergeService.selectWmsOutboundOrderMergeList(wmsOutboundOrderMerge);
        return getDataTable(list);
    }

    /**
     * 导出出库单合并列表
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:export')")
    @Log(title = "出库单合并", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsOutboundOrderMerge wmsOutboundOrderMerge)
    {
        List<WmsOutboundOrderMerge> list = wmsOutboundOrderMergeService.selectWmsOutboundOrderMergeList(wmsOutboundOrderMerge);
        ExcelUtil<WmsOutboundOrderMerge> util = new ExcelUtil<WmsOutboundOrderMerge>(WmsOutboundOrderMerge.class);
        util.exportExcel(response, list, "出库单合并数据");
    }

    /**
     * 获取出库单合并详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:query')")
    @GetMapping(value = "/{newOrderId}")
    public AjaxResult getInfo(@PathVariable("newOrderId") Long newOrderId)
    {
        return success(wmsOutboundOrderMergeService.selectWmsOutboundOrderMergeByNewOrderId(newOrderId));
    }

    /**
     * 新增出库单合并
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:add')")
    @Log(title = "出库单合并", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsOutboundOrderMerge wmsOutboundOrderMerge)
    {
        return toAjax(wmsOutboundOrderMergeService.insertWmsOutboundOrderMerge(wmsOutboundOrderMerge));
    }

    /**
     * 修改出库单合并
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:edit')")
    @Log(title = "出库单合并", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsOutboundOrderMerge wmsOutboundOrderMerge)
    {
        return toAjax(wmsOutboundOrderMergeService.updateWmsOutboundOrderMerge(wmsOutboundOrderMerge));
    }

    /**
     * 删除出库单合并
     */
    @PreAuthorize("@ss.hasPermi('system:outboundMerge:remove')")
    @Log(title = "出库单合并", businessType = BusinessType.DELETE)
	@DeleteMapping("/{newOrderIds}")
    public AjaxResult remove(@PathVariable Long[] newOrderIds)
    {
        return toAjax(wmsOutboundOrderMergeService.deleteWmsOutboundOrderMergeByNewOrderIds(newOrderIds));
    }
}
